package com.cskaoyan.shopping.controller.yjc;

import com.cskaoyan.mall.commons.result.ResponseData;
import com.cskaoyan.mall.dto.ProductDetailDto;
import com.cskaoyan.shopping.dto.AllProductResponse;
import com.cskaoyan.shopping.dto.ProductCateDto;
import com.cskaoyan.shopping.form.PageRequest;
import com.cskaoyan.shopping.service.yjc.IProductCateService_yjc;
import com.cskaoyan.shopping.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import com.cskaoyan.mall.commons.result.ResponseUtil;

/**
 * @author bolan
 * @date 2023-01-10 17:04
 * @describe
 */
@RestController
public class ShopingController {
    @Autowired
    IProductService iProductService;

    @Autowired
    IProductCateService_yjc iProductCateService_y;

    @GetMapping("/shopping/categories")
    public ResponseData categories() {
        List<ProductCateDto> allProductCate = iProductCateService_y.getAllProductCate();
        return new ResponseUtil().setData(allProductCate);
    }
@GetMapping("/shopping/product/{id}")
    public ResponseData product(@PathVariable("id") long id){

    ProductDetailDto productDetail = iProductService.getProductDetail(id);
    return new ResponseUtil().setData(productDetail);
}
    @GetMapping("/shopping/goods")
    public ResponseData goods( PageRequest pageInfo){
        AllProductResponse allProduct = iProductService.getAllProduct(pageInfo);
        return new ResponseUtil().setData(allProduct);
    }

}
